package org.cs.mgr.before.ctl;

import java.util.List;
import java.util.Map;

import org.cs.mgr.before.model.Goods;
import org.cs.mgr.before.model.User;
import org.cs.mgr.before.service.IFindService;
import org.cs.mgr.before.service.IGoodsService;
import org.cs.mgr.before.service.IUserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/reception")
public class IndexCtl {

	@Autowired
	IFindService findService;
	@Autowired
	IGoodsService  igoodsService;
	@Autowired
	IUserService   userService;
	
    //跳转首页页面
    @RequestMapping("index")
    public String indexUI(ModelMap mm) {
    	System.out.println("首页");
        List<Goods> goods = igoodsService.getGoodList();       //查询goods表,返回list集合（集合里是goods对象）
        mm.put("goodslist", goods);
		return "jsp/index";
    }
	
    //访问发现主页 
    @RequestMapping("index_find")
    public String  index_findUI(ModelMap mm,String type){
    	if(type==null){
    		type="1";
    	}
    	List<Map<String, Object>> findGoods = findService.getFindGoods();
    	mm.put("findList", findGoods);
    	mm.put("type", type);
        return "jsp/index_find";
    }

    
    //订单页面
    @RequestMapping("/index_my")
    public String  index_myUI(ModelMap mm,String id){
    	id="1";
    	User user = userService.getUser(id);
    	mm.put("user", user);
        return "jsp/index_my";
    }


}
